From ba09124f9f88f9e28b2cabf445606c3f44ec52f7 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Thu, 26 Dec 2013 22:45:03 -0500 Subject: [PATCH] GtkMenuTracker: tweak separator logic Ignacio Casal Quinteiro reported a problem whereby an empty section at the start of a menu has a separator placed after it. This was caused by the implementation of the logic that separators should be inserted at the top of all non-empty sections that are not the first section. This logic is obviously incorrect in the case that the first section is empty (in which case we would not expect to see a separator at the top of the second section). Change the logic so that we only insert separators when we see a non-zero number of actual items in the menu before us. https://bugzilla.gnome.org/show_bug.cgi?id=721119 --- gtk/gtkmenutracker.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk/gtkmenutracker.c b/gtk/gtkmenutracker.c index 6f0f4ba8db..6027520cba 100644 --- a/gtk/gtkmenutracker.c +++ b/gtk/gtkmenutracker.c @@ -141,8 +141,8 @@ gtk_menu_tracker_section_find_model (GtkMenuTrackerSection *section, * * could_have_separator is true in two situations: * - * - our parent section had with_separators defined and we are not the - * first section (ie: we should add a separator if we have content in + * - our parent section had with_separators defined and there are items + * before us (ie: we should add a separator if we have content in * order to divide us from the items above) * * - if we had a 'label' attribute set for this section @@ -177,7 +177,7 @@ gtk_menu_tracker_section_sync_separators (GtkMenuTrackerSection *section, { gboolean could_have_separator; - could_have_separator = (section->with_separators && i > 0) || + could_have_separator = (section->with_separators && n_items > 0) || g_menu_model_get_item_attribute (section->model, i, "label", "s", NULL); n_items += gtk_menu_tracker_section_sync_separators (subsection, tracker, offset + n_items, -- 2.30.2